
describe("MoveFromListController controller", function(){

    var controller = null;
    var objE = {errorCode:'code', errorMessage:'message'};

    beforeEach(function(){

        var t_alertCtrl = App.AlertController.create();
        var t_loadingCtrl = App.LoadingController.create();
        var t_moveHolderCtrl = App.MoveHolderController.create();
        App.MoveFromListController.reopen({

            init:function(){
                this.set('controllers.alert', t_alertCtrl);
                this.set('controllers.loading', t_loadingCtrl);
                this.set('controllers.moveHolder', t_moveHolderCtrl);
            }
        });
        controller = App.MoveFromListController.create();
    });



    it("prepareController", function(){

        var fromList = [];
        spyOn(controller, 'showLoading');
        spyOn(App.api_transfer,'fetchFromListForTransfer').andCallFake(function(transfer, callback){
            callback(fromList, BreezeException.create(objE));
        });

        controller.prepareController();
        expect(controller.showLoading).toHaveBeenCalled();
        expect(App.api_transfer.fetchFromListForTransfer).toHaveBeenCalled();
    });

    it("fromListCallback", function(){

        spyOn(controller, 'hasError').andReturn(false);
        spyOn(controller, 'hideLoading');

        controller.fromListCallback([], objE);

        expect(controller.hasError).toHaveBeenCalledWith(objE, false);
        expect(controller.hideLoading).toHaveBeenCalled();
    });
    it("selectListItem", function(){

        spyOn(controller,'setSourceAccount');
        spyOn(controller, 'transitionTo');

        var account = App.BaseAccount.create();

        controller.selectListItem(account);

        expect(controller.setSourceAccount).toHaveBeenCalledWith(account);
        expect(controller.transitionTo).toHaveBeenCalledWith('move.amount');
    });
    it("setSourceAccount", function(){

        spyOn(App.getSession(), 'getCurrentTransfer').andReturn(Ember.Object.create());
        controller.setSourceAccount({});
        expect(App.getSession().getCurrentTransfer).toHaveBeenCalled();
    });
});